package com.example.musicdemo.ui.activity

import android.os.Parcel
import android.os.Parcelable
import android.view.View
import androidx.core.view.ViewCompat
import androidx.core.view.ViewPropertyAnimatorListener
import com.example.musicdemo.R
import com.example.musicdemo.base.BaseActivity
import kotlinx.android.synthetic.main.activity_splash.*
import com.example.musicdemo.ui.activity.MainActivity as MainActivity

class SplashActivity() : BaseActivity(), Parcelable, ViewPropertyAnimatorListener {

    constructor(parcel: Parcel) : this()

    override fun writeToParcel(parcel: Parcel, flags: Int) {

    }

    override fun describeContents(): Int {

        return 0
    }

    companion object CREATOR : Parcelable.Creator<SplashActivity> {
        override fun createFromParcel(parcel: Parcel): SplashActivity {
            return SplashActivity(parcel)
        }

        override fun newArray(size: Int): Array<SplashActivity?> {
            return arrayOfNulls(size)
        }
    }

    override fun initData() {
        ViewCompat.animate(iv_splash).scaleX(1.0f).scaleY(1.0f).setListener(this).duration = 2000
    }

    override fun initListener() {
    }

    override fun getLayoutId(): Int {
        return R.layout.activity_splash
    }


    override fun onAnimationStart(view: View?) {
    }


    /**
     * 动画结束后调整
     */
    override fun onAnimationEnd(view: View?) {
        //跳转到主界面
        startAndFinishActivity<MainActivity>()
    }

    override fun onAnimationCancel(view: View?) {
    }
}